package org.linlinjava.litemall.db.domain;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Arrays;

public class LitemallMerchandiseLog {
    public static final Boolean IS_DELETED = Deleted.IS_DELETED.value();

    public static final Boolean NOT_DELETED = Deleted.NOT_DELETED.value();

    private Integer id;

    private Integer shopId;

    private Integer merchandiseId;

    private Integer adminOrderId;

    private String merchandiseImage;

    private String merchandiseName;

    private BigDecimal payPrice;

    private String merchandiseSn;

    private String orderSn;

    private String purchaseQuantity;

    private String remainingNumber;

    private Byte operationType;

    private String content;

    private String remark;

    private String userName;

    private Byte logType;

    private Boolean deleted;

    private LocalDateTime addTime;

    private Integer addUserId;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Integer getShopId() {
        return shopId;
    }

    public void setShopId(Integer shopId) {
        this.shopId = shopId;
    }

    public Integer getMerchandiseId() {
        return merchandiseId;
    }

    public void setMerchandiseId(Integer merchandiseId) {
        this.merchandiseId = merchandiseId;
    }

    public Integer getAdminOrderId() {
        return adminOrderId;
    }

    public void setAdminOrderId(Integer adminOrderId) {
        this.adminOrderId = adminOrderId;
    }

    public String getMerchandiseImage() {
        return merchandiseImage;
    }

    public void setMerchandiseImage(String merchandiseImage) {
        this.merchandiseImage = merchandiseImage;
    }

    public String getMerchandiseName() {
        return merchandiseName;
    }

    public void setMerchandiseName(String merchandiseName) {
        this.merchandiseName = merchandiseName;
    }

    public BigDecimal getPayPrice() {
        return payPrice;
    }

    public void setPayPrice(BigDecimal payPrice) {
        this.payPrice = payPrice;
    }

    public String getMerchandiseSn() {
        return merchandiseSn;
    }

    public void setMerchandiseSn(String merchandiseSn) {
        this.merchandiseSn = merchandiseSn;
    }

    public String getOrderSn() {
        return orderSn;
    }

    public void setOrderSn(String orderSn) {
        this.orderSn = orderSn;
    }

    public String getPurchaseQuantity() {
        return purchaseQuantity;
    }

    public void setPurchaseQuantity(String purchaseQuantity) {
        this.purchaseQuantity = purchaseQuantity;
    }

    public String getRemainingNumber() {
        return remainingNumber;
    }

    public void setRemainingNumber(String remainingNumber) {
        this.remainingNumber = remainingNumber;
    }

    public Byte getOperationType() {
        return operationType;
    }

    public void setOperationType(Byte operationType) {
        this.operationType = operationType;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public Byte getLogType() {
        return logType;
    }

    public void setLogType(Byte logType) {
        this.logType = logType;
    }

    public void andLogicalDeleted(boolean deleted) {
        setDeleted(deleted ? Deleted.IS_DELETED.value() : Deleted.NOT_DELETED.value());
    }

    public Boolean getDeleted() {
        return deleted;
    }

    public void setDeleted(Boolean deleted) {
        this.deleted = deleted;
    }

    public LocalDateTime getAddTime() {
        return addTime;
    }

    public void setAddTime(LocalDateTime addTime) {
        this.addTime = addTime;
    }

    public Integer getAddUserId() {
        return addUserId;
    }

    public void setAddUserId(Integer addUserId) {
        this.addUserId = addUserId;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", IS_DELETED=").append(IS_DELETED);
        sb.append(", NOT_DELETED=").append(NOT_DELETED);
        sb.append(", id=").append(id);
        sb.append(", shopId=").append(shopId);
        sb.append(", merchandiseId=").append(merchandiseId);
        sb.append(", adminOrderId=").append(adminOrderId);
        sb.append(", merchandiseImage=").append(merchandiseImage);
        sb.append(", merchandiseName=").append(merchandiseName);
        sb.append(", payPrice=").append(payPrice);
        sb.append(", merchandiseSn=").append(merchandiseSn);
        sb.append(", orderSn=").append(orderSn);
        sb.append(", purchaseQuantity=").append(purchaseQuantity);
        sb.append(", remainingNumber=").append(remainingNumber);
        sb.append(", operationType=").append(operationType);
        sb.append(", content=").append(content);
        sb.append(", remark=").append(remark);
        sb.append(", userName=").append(userName);
        sb.append(", logType=").append(logType);
        sb.append(", deleted=").append(deleted);
        sb.append(", addTime=").append(addTime);
        sb.append(", addUserId=").append(addUserId);
        sb.append("]");
        return sb.toString();
    }

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        LitemallMerchandiseLog other = (LitemallMerchandiseLog) that;
        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
            && (this.getShopId() == null ? other.getShopId() == null : this.getShopId().equals(other.getShopId()))
            && (this.getMerchandiseId() == null ? other.getMerchandiseId() == null : this.getMerchandiseId().equals(other.getMerchandiseId()))
            && (this.getAdminOrderId() == null ? other.getAdminOrderId() == null : this.getAdminOrderId().equals(other.getAdminOrderId()))
            && (this.getMerchandiseImage() == null ? other.getMerchandiseImage() == null : this.getMerchandiseImage().equals(other.getMerchandiseImage()))
            && (this.getMerchandiseName() == null ? other.getMerchandiseName() == null : this.getMerchandiseName().equals(other.getMerchandiseName()))
            && (this.getPayPrice() == null ? other.getPayPrice() == null : this.getPayPrice().equals(other.getPayPrice()))
            && (this.getMerchandiseSn() == null ? other.getMerchandiseSn() == null : this.getMerchandiseSn().equals(other.getMerchandiseSn()))
            && (this.getOrderSn() == null ? other.getOrderSn() == null : this.getOrderSn().equals(other.getOrderSn()))
            && (this.getPurchaseQuantity() == null ? other.getPurchaseQuantity() == null : this.getPurchaseQuantity().equals(other.getPurchaseQuantity()))
            && (this.getRemainingNumber() == null ? other.getRemainingNumber() == null : this.getRemainingNumber().equals(other.getRemainingNumber()))
            && (this.getOperationType() == null ? other.getOperationType() == null : this.getOperationType().equals(other.getOperationType()))
            && (this.getContent() == null ? other.getContent() == null : this.getContent().equals(other.getContent()))
            && (this.getRemark() == null ? other.getRemark() == null : this.getRemark().equals(other.getRemark()))
            && (this.getUserName() == null ? other.getUserName() == null : this.getUserName().equals(other.getUserName()))
            && (this.getLogType() == null ? other.getLogType() == null : this.getLogType().equals(other.getLogType()))
            && (this.getDeleted() == null ? other.getDeleted() == null : this.getDeleted().equals(other.getDeleted()))
            && (this.getAddTime() == null ? other.getAddTime() == null : this.getAddTime().equals(other.getAddTime()))
            && (this.getAddUserId() == null ? other.getAddUserId() == null : this.getAddUserId().equals(other.getAddUserId()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
        result = prime * result + ((getShopId() == null) ? 0 : getShopId().hashCode());
        result = prime * result + ((getMerchandiseId() == null) ? 0 : getMerchandiseId().hashCode());
        result = prime * result + ((getAdminOrderId() == null) ? 0 : getAdminOrderId().hashCode());
        result = prime * result + ((getMerchandiseImage() == null) ? 0 : getMerchandiseImage().hashCode());
        result = prime * result + ((getMerchandiseName() == null) ? 0 : getMerchandiseName().hashCode());
        result = prime * result + ((getPayPrice() == null) ? 0 : getPayPrice().hashCode());
        result = prime * result + ((getMerchandiseSn() == null) ? 0 : getMerchandiseSn().hashCode());
        result = prime * result + ((getOrderSn() == null) ? 0 : getOrderSn().hashCode());
        result = prime * result + ((getPurchaseQuantity() == null) ? 0 : getPurchaseQuantity().hashCode());
        result = prime * result + ((getRemainingNumber() == null) ? 0 : getRemainingNumber().hashCode());
        result = prime * result + ((getOperationType() == null) ? 0 : getOperationType().hashCode());
        result = prime * result + ((getContent() == null) ? 0 : getContent().hashCode());
        result = prime * result + ((getRemark() == null) ? 0 : getRemark().hashCode());
        result = prime * result + ((getUserName() == null) ? 0 : getUserName().hashCode());
        result = prime * result + ((getLogType() == null) ? 0 : getLogType().hashCode());
        result = prime * result + ((getDeleted() == null) ? 0 : getDeleted().hashCode());
        result = prime * result + ((getAddTime() == null) ? 0 : getAddTime().hashCode());
        result = prime * result + ((getAddUserId() == null) ? 0 : getAddUserId().hashCode());
        return result;
    }

    public enum Deleted {
        NOT_DELETED(new Boolean("0"), "未删除"),
        IS_DELETED(new Boolean("1"), "已删除");

        private final Boolean value;

        private final String name;

        Deleted(Boolean value, String name) {
            this.value = value;
            this.name = name;
        }

        public Boolean getValue() {
            return this.value;
        }

        public Boolean value() {
            return this.value;
        }

        public String getName() {
            return this.name;
        }
    }

    public enum Column {
        id("id", "id", "INTEGER", false),
        shopId("shop_id", "shopId", "INTEGER", false),
        merchandiseId("merchandise_id", "merchandiseId", "INTEGER", false),
        adminOrderId("admin_order_id", "adminOrderId", "INTEGER", false),
        merchandiseImage("merchandise_image", "merchandiseImage", "VARCHAR", false),
        merchandiseName("merchandise_name", "merchandiseName", "VARCHAR", false),
        payPrice("pay_price", "payPrice", "DECIMAL", false),
        merchandiseSn("merchandise_sn", "merchandiseSn", "VARCHAR", false),
        orderSn("order_sn", "orderSn", "VARCHAR", false),
        purchaseQuantity("purchase_quantity", "purchaseQuantity", "VARCHAR", false),
        remainingNumber("remaining_number", "remainingNumber", "VARCHAR", false),
        operationType("operation_type", "operationType", "TINYINT", false),
        content("content", "content", "VARCHAR", false),
        remark("remark", "remark", "VARCHAR", false),
        userName("user_name", "userName", "VARCHAR", false),
        logType("log_type", "logType", "TINYINT", false),
        deleted("deleted", "deleted", "BIT", false),
        addTime("add_time", "addTime", "TIMESTAMP", false),
        addUserId("add_user_id", "addUserId", "INTEGER", false);

        private static final String BEGINNING_DELIMITER = "`";

        private static final String ENDING_DELIMITER = "`";

        private final String column;

        private final boolean isColumnNameDelimited;

        private final String javaProperty;

        private final String jdbcType;

        public String value() {
            return this.column;
        }

        public String getValue() {
            return this.column;
        }

        public String getJavaProperty() {
            return this.javaProperty;
        }

        public String getJdbcType() {
            return this.jdbcType;
        }

        Column(String column, String javaProperty, String jdbcType, boolean isColumnNameDelimited) {
            this.column = column;
            this.javaProperty = javaProperty;
            this.jdbcType = jdbcType;
            this.isColumnNameDelimited = isColumnNameDelimited;
        }

        public String desc() {
            return this.getEscapedColumnName() + " DESC";
        }

        public String asc() {
            return this.getEscapedColumnName() + " ASC";
        }

        public static Column[] excludes(Column ... excludes) {
            ArrayList<Column> columns = new ArrayList<>(Arrays.asList(Column.values()));
            if (excludes != null && excludes.length > 0) {
                columns.removeAll(new ArrayList<>(Arrays.asList(excludes)));
            }
            return columns.toArray(new Column[]{});
        }

        public String getEscapedColumnName() {
            if (this.isColumnNameDelimited) {
                return new StringBuilder().append(BEGINNING_DELIMITER).append(this.column).append(ENDING_DELIMITER).toString();
            } else {
                return this.column;
            }
        }

        public String getAliasedEscapedColumnName() {
            return this.getEscapedColumnName();
        }
    }
}